package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
	//"github.com/github-user/IMv_3/routes"
	"github.com/gin-contrib/sessions"
	"github.com/gin-contrib/sessions/cookie"
	"github.com/github-user/TokTik/controllers"
)

func main() {
	r := gin.Default()
	store := cookie.NewStore([]byte("secret"))
	r.Use(sessions.Sessions("sessionid", store))
	api := r.Group("/api")
	{
		usr := api.Group("/user")
		{
			usr.POST("/register", controllers.Register)

			usr.POST("/login", controllers.Login)

			//usr.GET("/connect", controllers.ConnectWeb)

			usr.GET("/id/:id", controllers.GetUserMessageByID)

			usr.Use(controllers.Authorize())

			usr.GET("/self", controllers.GetSelfMessage)

			usr.PUT("/message", controllers.ChangeMessage)

		}

		moment := api.Group("/video")
		{
			moment.GET("/some", controllers.GetPage)

			moment.POST("/publish", controllers.PublishVideo)

			moment.StaticFS("/public/", http.Dir("upload"))

			moment.Use(controllers.Authorize())

			moment.GET("/all", controllers.GetVideos)

			moment.POST("/comment", controllers.AddComment)

			moment.GET("/all/:fid", controllers.GetUserVideos)

			moment.POST("/like", controllers.AddLike)

			moment.POST("/star", controllers.StarVideo)

			moment.GET("/getstar", controllers.GetStar)

			moment.DELETE("/delete/:id", controllers.DeleteStar)
		}
	}
	r.Run(":8081")
}
